﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;
using log4net;

namespace API_Service
{
    public class Logger
    {
        log4net.ILog log = log4net.LogManager.GetLogger("API.Logging");//获取一个日志记录器

        public Logger()
        {
            //。。。
        }

        public void WriteInfo(string message)
        {
            log.Info(message);
        }
        public void WriteInfo(string message, Exception ex)
        {
            log.Info(message, ex);
        }
        public void WriteInfo(MethodBase method, string message)
        {
            log.Info(MethodBase.GetCurrentMethod().ReflectedType.FullName + "."
                + MethodBase.GetCurrentMethod().Name + @"\r\n" + message);
        }
        public void WriteInfo(MethodBase method, Exception ex)
        {
            log.Info(MethodBase.GetCurrentMethod().ReflectedType.FullName + "."
                + MethodBase.GetCurrentMethod().Name, ex);
        }

        public void WriteError(string message)
        {
            log.Error(message);
        }
        public void WriteError(string message, Exception ex)
        {
            log.Error(message, ex);
        }
        public void WriteError(MethodBase method,string message)
        {
            log.Error(MethodBase.GetCurrentMethod().ReflectedType.FullName + "." 
                + MethodBase.GetCurrentMethod().Name + @"\r\n" + message);
        }
        public void WriteError(MethodBase method, Exception ex)
        {
            log.Error(MethodBase.GetCurrentMethod().ReflectedType.FullName + "."
                + MethodBase.GetCurrentMethod().Name, ex);
        }

        public void WriteDebug(string message)
        {
            log.Debug(message);
        }
        public void WriteDebug(string message, Exception ex)
        {
            log.Debug(message, ex);
        }
        public void WriteDebug(MethodBase method, string message)
        {
            log.Debug(MethodBase.GetCurrentMethod().ReflectedType.FullName + "."
                + MethodBase.GetCurrentMethod().Name + @"\r\n" + message);
        }
        public void WriteDebug(MethodBase method, Exception ex)
        {
            log.Debug(MethodBase.GetCurrentMethod().ReflectedType.FullName + "."
                + MethodBase.GetCurrentMethod().Name, ex);
        }

        public void WriteFatal(string message)
        {
            log.Fatal(message);
        }
        public void WriteFatal(string message, Exception ex)
        {
            log.Fatal(message, ex);
        }
        public void WriteFatal(MethodBase method, string message)
        {
            log.Fatal(MethodBase.GetCurrentMethod().ReflectedType.FullName + "."
                + MethodBase.GetCurrentMethod().Name + @"\r\n" + message);
        }
        public void WriteFatal(MethodBase method, Exception ex)
        {
            log.Fatal(MethodBase.GetCurrentMethod().ReflectedType.FullName + "."
                + MethodBase.GetCurrentMethod().Name, ex);
        }


    }
}